// pages/newsInfo/newsInfo.js
import { request } from "../../request/index.js";
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    newsInfo: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let pages = getCurrentPages();
    let currentPage = pages[pages.length - 1];
    let options = currentPage.options;
    const { id } = options;
    this.getNewsInfo(id);

  },
  async getNewsInfo(id) {
    const res = await request({ url: "/news/selectNewsById", data: { id } })
    this.setData({
      newsInfo: res
    })
  }
})